1. /* scftanbs.cpp by K.Tsuru */
  2. // function ID = 9123 since ver.2.18
  3. /*****************************************
  4. SComplex class
  5. It returns tan(z) using binary splitting method.
  6. Let z = x+iy,
  7. tan(z) = {sin(2*x)+i*sinh(2*y)}/{cos(2*x)+cosh(2*y)}.
  8. *****************************************/
  9. #ifndef SN_H
  10. #include "sn.h"
  11. #endif
  12. SComplex CtanBS(const SComplex& z){
  13. SDouble c2, s2, ch2, sh2;
  14. CosSinBS(2 * z.Real(), c2, s2); // c2 = cos(2x), s2 = sin(2x)
  15. SDouble e, r;
  16. int ys = z.Imag().Sign(9122);
  17. if(ys > 0) { // y > 0
  18. e = ExpBS(2 * z.Imag()); // = exp(2y)
  19. r = 1/e;
  20. ch2 = DDiv2(e + r); // = cosh(2y)
  21. sh2 = ch2 - r; // = sinh(2y)
  22. } else if(ys == 0) { // y = 0
  23. ch2 = 1; sh2 = 0.0;
  24. } else { // y < 0
  25. e = ExpBS(-2 * z.Imag()); // = exp(-2y)
  26. r = 1/e;
  27. ch2 = DDiv2(e + r); // = cosh(-2y)
  28. sh2 = ch2 - e; // = -sinh(-2y)
  29. }
  30. SDouble r_den, rr, ri;
  31. r_den = 1.0/(c2 + ch2);
  32. rr = s2 * r_den;
  33. ri = sh2 * r_den;
  34. return SComplex(rr, ri);
  35. }

scftanbs.cpp : last modifiled at 2008/12/08 16:37:56(999 bytes)
created at 2017/10/06 15:21:28
The creation time of this html file is 2017/10/06 15:27:09 (Fri Oct 06 15:27:09 2017).